﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace School
{
    public class Course
    {
        private static readonly int LIMIT = 30;

        private int count = 0;
        private HashSet<Student> set = null;

        public Course()
        {
            this.set = new HashSet<Student>();
        }

        public void Join(Student student)
        {
            if (this.count == LIMIT)
            {
                throw new Exception("This course is full max");
            }
            if (this.set.Contains(student))
            {
                throw new Exception("This student already exists in this course");
            }
            set.Add(student);
            this.count++;
        }

        public void Leave(Student student)
        {
            if (this.count == 0)
            {
                throw new Exception("This course is empty");
            }
            if (this.set.Contains(student) == false)
            {
                throw new Exception("This student is not in the course");
            }
            set.Remove(student);
            this.count--;
        }
    }
}
